<!doctype html>
<html lang="en">
<head>
<title>设备故障报修</title>

<meta name="keywords" content="keyword1,keyword2,keyword3">
<meta name="description" content="设备故障报修">
<meta name="content-type" content="text/html; charset=UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="format-detection" content="telephone=no">
<script src="../../script/js/echart/js/jquery-3.2.1.min.js"></script>
<link rel="stylesheet" type="text/css" href="../../script/js/layui/css/layui.css" media="all">
<script type="text/javascript" src="../../script/js/layui/layui.js"></script>
<script type="text/javascript" src="../../mes/js/vue.min.js"></script>
<script type="text/javascript" src="../../mes/js/vue-resource.min.js"></script>
</head>

<body id="production">
<form class="layui-form layui-form-pane">
 <fieldset class="layui-elem-field layui-field-title">
  <legend><font color="white">设备信息-故障类型</font></legend>
			<div class="layui-form-item" >
				<div class="layui-inline">
						<label class="layui-form-label" style="width:130px;">车间：</label> 
						<div class="layui-input-inline" style="width:330px;">
						<select name="modules" lay-verify="required" lay-search=""  lay-filter="adorgid">
								<option value="">直接选择或搜索选择</option>
								<option v-for="allorg in allorgs" value="{{allorg.NAME}}">{{allorg.NAME}}</option>
							</select>
						</div>
				</div>
				
				<div class="layui-inline">
						<label class="layui-form-label" style="width:130px;">工序：</label> 
						<div class="layui-input-inline" style="width:330px;">
						<select name="modules" lay-verify="required" lay-search=""  lay-filter="gongxuIds">
								<option value="">直接选择或搜索选择</option>
								<option v-for="processname in processnames" value="{{processname.NAME}}">{{processname.NAME}}</option>
							</select>
						</div>
				</div>
			</div>
			
			
			<!-- 正常生产设备报修的流程 -->
			<div class="layui-form-item" id = "normal">
								
				<div class="layui-inline">
			      <label class="layui-form-label" style="width:130px;" >设备编码-名称：</label>
			      <div class="layui-input-inline" style="width:330px;">
			        <select name="modules" lay-verify="required" lay-search="" lay-filter="processId">
			        	<option value="">直接选择或搜索选择</option>
			          	<option v-for="sel in sels" value="{{sel.CODE}}">{{sel.CODE}}——{{sel.NAME}}</option>
			        </select>
			      </div>
			    </div>
				
				
				<div class="layui-inline">
						<label class="layui-form-label" style="width:130px;">故障类型：</label> 
						<div class="layui-input-inline" style="width:330px;">
						<select name="modules" lay-verify="required" lay-search="" id="seType">
								<option value="">直接选择或搜索选择</option>
								<option v-for="all in alls" value="{{all.TYPE}}">{{all.TYPE}}</option>
							</select>
						</div>
				</div>
				</div>
				
				<!-- 花篮报修显示的内容 -->
				<div class="layui-form-item" id = "abnormal">
					<div class="layui-inline">
			      		<label class="layui-form-label" style="width:130px;" >花篮编码-名称：</label>
			      		<div class="layui-input-inline" style="width:330px;">
			        		<select name="modules" lay-verify="required" lay-search="" lay-filter="hualanId">
			        			<option value="">直接选择或搜索选择</option>
			          			<option v-for="hualan in basket" value="{{hualan.CODE}}">{{hualan.CODE}}——{{hualan.NAME}}</option>
			        		</select>
			      		</div>
			   	     </div>
				</div>
				
				
	</fieldset>		
			
			
  <fieldset class="layui-elem-field layui-field-title" id = 'window1'>
  <legend><font color="white">故障报修设备信息</font></legend>
			<div class="layui-form-item">
				
				<div class="layui-inline">
						<label class="layui-form-label" style="width:130px;color:gray;"> 设备名称：</label>
						<div class="layui-input-inline" style="width:330px;color:gray;">
							<input type="text" class="layui-input" v-model="manuOrder.NAME" disabled=""style="color:gray;">
						</div>
				</div>
			
			 </div>	
			<div class="layui-form-item">
					<div class="layui-inline">
						<label class="layui-form-label" style="width:130px;color:gray;"> 车间：</label>
						<div class="layui-input-inline" style="width:330px;color:gray;">
							<input type="text" class="layui-input" v-model="manuOrder.BZNAME" disabled=""style="color:gray;">
						</div>
				    </div>
				
					
					<div class="layui-inline">
						<label class="layui-form-label" style="width:130px;color:gray;"> 设备责任人：</label>
						<div class="layui-input-inline" style="width:330px;color:gray;">
							<input type="text" id='zerenren' class="layui-input" v-model="manuOrder.YHNAME" disabled=""style="color:gray;">
						</div>
				    </div>
			 </div>
			    
			    
				
	</fieldset>
	
	 <fieldset class="layui-elem-field layui-field-title" id='window2'>
	 <legend><font color="white">说明描述</font></legend>
  				<div>
  					<label class="layui-form-label" style="height: 38px;">设备状态</label>
  					<div class="layui-input-inline" style="background-color:#ffffff; height: 38px;">
  					<input type="radio" name="type" value="N" title="运行" checked>
  					<input type="radio" name="type" value="Y" title="停机" >
  					</div>
				</div>					
				<div class="layui-form-item layui-form-text">
					 <label class="layui-form-label" style="width:960px;">故障说明：</label>
					 <div class="layui-input-block">
					 <textarea placeholder="请输入内容" class="layui-textarea" id="workflowrank" style="width:960px; height:200px; "></textarea>
					 </div>
					    
  				</div>
			
	</fieldset>
				
	<div class="layui-form-item" id='window4'> 
		<button type="button"  class="layui-btn" @click="saveProductionData">提交</button>
		&nbsp;&nbsp;&nbsp;
		<button type="button"  class="layui-btn" @click="reset">重置</button>
		&nbsp;&nbsp;&nbsp;
		<button type="button"  class="layui-btn" @click="flowerbasket">花篮报修</button>
	</div>
	
	<fieldset class="layui-elem-field layui-field-title" id='window2'>
	 <legend><font color="white">报修记录</font></legend>
	     <div style="border-right: 2px #f0f0f0 solid;">
  			<iframe id="beforeBackOut" width="1800px" height="400px" src="http://10.3.11.195:8090/report/show/index.jsp?id=75b9b101e10e4611bfd31963648c8a23" frameborder="0"></iframe>
  		</div>
	 	
	 </fieldset>
</form>
	<script type="text/javascript">
		if(window.location.host.indexOf("192.168")>-1){
            $("#beforeBackOut").attr("src","http://192.168.32.13:18080/report/show/index.jsp?id=75b9b101e10e4611bfd31963648c8a23");
        }else{
            $("#beforeBackOut").attr("src","http://"+window.location.host+"/report/show/index.jsp?id=75b9b101e10e4611bfd31963648c8a23");
        }
     var vm = new Vue({
		el : "#production",
		data : {
			sels:[],
			alls:[],
			basket:[],
			allorgs:[],
			processnames:[],
			selected:'',
			manuOrder:{}			
		},
		
		init:function(){
			 var _self = this;
	       	 this.$nextTick(function() {
					this.$http.post("../../Troubleshooting/devicecoding",{},{emulateJSON: true}).then(function(res){
						if(res.ok){
							_self.alls = res.body.faults;
							_self.allorgs = res.body.adorgname;
							_self.basket = res.body.baskets;
							$('#abnormal').hide();
						}
						layui.use(['form'], function(){
							var form = layui.form;
							
							form.on('select(adorgid)', function(data){
								 _self.adorgids = data.value;
						         $.ajax({
								    url: "../../Troubleshooting/EquipmentProcess",
								    type: 'POST',
								    async: false,
								    data: {
								           ORGNAME:_self.adorgids
									},
								    dataType: 'json',
									success: function(data) {
									   if(data.result){										   	   
									   	   _self.processnames = data.processname;
									   	   									   	   
									   	   window.setTimeout(function() {
									   	   		form.render("select");
									   	   }, 100);
									   	   
									   }else{
									       layer.msg("处理失败");
									   }
									}
								});
						   	});
							
							form.on('select(gongxuIds)', function(data){
								 _self.gongxuId = data.value;
						         $.ajax({
								    url: "../../Troubleshooting/Equipmentcode",
								    type: 'POST',
								    async: false,
								    data: {
								           ORGNAME:_self.adorgids,
								           GXNAME:_self.gongxuId
									},
								    dataType: 'json',
									success: function(data) {
									   if(data.result){										   	   
									   	   _self.sels = data.Plans;
									   	   									   	   
									   	   window.setTimeout(function() {
									   	   		form.render("select");
									   	   }, 100);
									   	   
									   }else{
									       layer.msg("处理失败");
									   }
									}
								});
						   	});
							
							
								//正常设备的查询（带出设备的相应信息）
								form.on('select(processId)', function(data){ 
									 _self.selected = data.value;
							         $.ajax({
									    url: "../../Troubleshooting/EquipmentInformation",
									    type: 'POST',
									    async: false,
									    data: {
									           CODE:_self.selected
										},
									    dataType: 'json',
										success: function(data) {
										   if(data.result){										   	   
										   	   _self.manuOrder = data.failices[0];
										   	   									   	   
										   	   window.setTimeout(function() {
										   	   		form.render("select");
										   	   }, 100);
										   	   if(_self.manuOrder.STATUS == 'USE'){
										   	  	_self.manuOrder.STATUS = '正常'
										   	  }else if(_self.manuOrder.STATUS == 'FREE'){
										   	  	_self.manuOrder.STATUS = '封存'
										   	  }else if(_self.manuOrder.STATUS == 'STOP'){
										   	  	_self.manuOrder.STATUS = '报废'
										   	  }
										   }else{
										       layer.msg("处理失败");
										   }
										}
									});
							   	});
							
								//花篮的查询（带出花篮的相应信息）
								form.on('select(hualanId)', function(data){ 
									 _self.selected1 = data.value;
							         $.ajax({
									    url: "../../Troubleshooting/EquipmentInformation",
									    type: 'POST',
									    async: false,
									    data: {
									           HLCODE:_self.selected1
										},
									    dataType: 'json',
										success: function(data) {
										   if(data.result){										   	   
										   	   _self.manuOrder = data.failices[0];
										   	   									   	   
										   	   window.setTimeout(function() {
										   	   		form.render("select");
										   	   }, 100);
										   	   /* if(_self.manuOrder.STATUS == 'USE'){
										   	  	_self.manuOrder.STATUS = '正常'
										   	  }else if(_self.manuOrder.STATUS == 'FREE'){
										   	  	_self.manuOrder.STATUS = '封存'
										   	  }else if(_self.manuOrder.STATUS == 'STOP'){
										   	  	_self.manuOrder.STATUS = '报废'
										   	  } */
										   }else{
										       layer.msg("处理失败");
										   }
										}
									});
							   	});
							
						
					});
					});
			 }); 
			 
		},
		methods: {
		   refreshTable : function(){
		     layui.use(['form'], function(){
				 var form = layui.form;
				 form.render('select');
			 });
		   },
			saveProductionData:function(event){
				var _self = this;
				
				var Remarks = document.getElementById("workflowrank").value;  //获取维修说明输入框的值;
				var Equipmenttype = "REPAIR";									//区分保养维修的参数
				var types = $('#seType option:selected').val();        //故障类型
				var resultstype = $("input[name='type']:checked").val();  //获取设备是否停机
				var usernames = document.getElementById("zerenren").value;		 //责任人
				
				if(_self.gongxuId ==""){
					layer.msg("请选择工序！");
				}else{
					if(_self.adorgids == ""){
						layer.msg("请选择组织机构！");
					}else{
						if(_self.selected == "" && _self.selected1 == ""){
							 layer.msg("请选择设备编码！");
						}else{
								var data ={
								    SBCode : _self.selected,
								    HLCODE:_self.selected1,
								    Remarks : Remarks,
								    Equipmenttype : Equipmenttype,
									usernames : usernames,
									types : types,
									GongXuName : _self.gongxuId,
									ZuZhiJiGou : _self.adorgids,
									resultstype : resultstype
									};				
															
								  this.$nextTick(function() {
									  this.$http.post("../../Troubleshooting/SavaPendingMaintenanceList",data,{emulateJSON: true}).then(function(res){
										  if(res.ok){ 		
											  _self.result = res.body.results;	
											  _self.count = res.body.counts;
											  _self.projectscount = res.body.projectscounts;
											  
											 if(_self.projectscount == "false"){
											 	layer.msg("该设备未配置维修项目！");
											 }else{
												 if(_self.count == "false"){
												 	layer.msg("该设备已经报修！"); 
												 }else{
												 	 if(_self.result == "false"){
												 		layer.msg("报修失败"); 				
													  }else{	
														layer.msg("报修成功");
														window.setTimeout(function() {
															window.location.reload();
													        }, 1000);
													  }	
												 }	
											 }
											 				 							
											  
											 	
											  				
										  }else{
										   layer.msg("报修失败"); 	
										 }
									 });
							    }); 								 
							
						}
					}
				}
			},
			//重置按钮
			reset:function(data){
				window.location.reload();
			},
			//花篮报修流程
			flowerbasket:function(data){
				$('#abnormal').show();
			    $('#normal').hide();
			}
		}

	});
    </script>
</body>
</html>
